package com.ITArmy.controller.admin;

import com.ITArmy.beans.Chapter;
import com.ITArmy.common.ServerResponse;
import com.ITArmy.controller.base.BaseController;
import com.ITArmy.service.ChapterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(value = "后台章节接口层次", tags = "后台章节Controller")
@Controller
@RequestMapping("/admin/Chapter")
public class AdminChapterController extends BaseController {

    @RequestMapping("/addChapter")
    @ResponseBody
    @ApiOperation(value = "根据连载连载id添加章节（增）", httpMethod = "GET", response = ServerResponse.class)

    public ServerResponse addChapter(Chapter chapter) {
        return chapterService.addChapter(chapter);
    }

    @RequestMapping("/deleteChapter")
    @ResponseBody
    @ApiOperation(value = "根据连载连载id，和章节id删除指定的章节（删）", httpMethod = "POST", response = ServerResponse.class)

    public ServerResponse deleteChapter(int serializeId, int chapterId) {
        System.out.println(serializeId+"ssdadsadasda"+chapterId);
        return chapterService.deleteChapter(serializeId, chapterId);
    }

    @RequestMapping("/amendChapter")
    @ResponseBody
    @ApiOperation(value = "根据连载id和章节id修改章节内容（改）", httpMethod = "POST", response = ServerResponse.class)
    public ServerResponse amendChapter(Chapter chapter) {
        return chapterService.amendChapter(chapter);
    }

    @RequestMapping("/getAllChapter")
    @ResponseBody
    @ApiOperation(value = "根据连载id获取所有的章节（查）", httpMethod = "POST", response = ServerResponse.class)
    public ServerResponse getAllChapter(long serializeId) {
        return chapterService.getAllChapter(serializeId);
    }
}
